!function(e,o,r){o.behaviors.my_custom_behavior={attach(o,i){function n(e,o,r,i){const n=["1721","1722","1723","1724","1727","1734"];if(["1721","1722","1723","1724","1725","1726","1727","1728","1734","1735","1738","1739","1740"].includes(e))i.prepend('

'+o+"

"),n.includes(e)&&i.find('input[type="submit"]').attr("disabled",!0);else if("1729"!==e&&"1736"!==e||!1===r){if("1730"===e){let e;e=/^cons_/.test(r)?i.find('[data-luminate-field="'+r+'"]'):i.find('[name$="'+r+'"]'),e.attr("maxlength","255")}else if("1731"===e){let e;e=/^cons_/.test(r)?i.find('[data-luminate-field="'+r+'"]'):i.find('[name$="'+r+'"]'),e.attr("pattern","^[0-9]*$"),e.append('
")}else if("1732"===e||"1733"===e){let e;e=/^cons_/.test(r)?i.find('[data-luminate-field="'+r+'"]'):i.find('[name$="'+r+'"]'),e.append('
")}else if("1737"===e){let e;e=/^cons_birth/.test(r)?i.find('[data-luminate-field="'+r+'"]'):i.find('[name="'+r+'"]'),e.append('
")}}else{let n;n=/^cons_/.test(r)?i.find('[data-luminate-field="'+r+'"]'):i.find('[name$="'+r+'"]'),n.length>0?(n.attr("required","required"),n.parent().find("label").prepend('*')):"1729"===e?(i.append('

The specified survey is improperly configured.

'),i.find('input[type="submit"]').attr("disabled",!0)):"1736"===e&&i.append('

'+o+"

")}}function t(e){return'
'+e+"
"}function s(o){var r=new e.Deferred;return luminateExtend.api({api:"cons",callback:function(e){void 0!==e?r.resolve(e):r.reject()},data:"method=getUserInteractions&interaction_type_id="+o,requiresAuth:!0,useHTTPS:!0}),r}function a(e,o,r){try{var i=new CustomEvent("leadgenPX",{detail:{surveyId:o,name:r}});e[0].dispatchEvent(i)}catch(e){}}$body=e("body"),window.cookieDomain="savethechildren.org",luminateExtend.init({apiKey:r.scus_luminate_form.api_key,path:{nonsecure:"https://"+r.scus_luminate_form.js_url,secure:"https://"+r.scus_luminate_form.js_url}}),e.fn.LuminateAjaxFormSubmit=function(o,r,i,d,m){let c="method=submitSurvey&"+function(e){const o=Object.entries(e).map((([e,o])=>Array.isArray(o)?o.map((o=>`${encodeURIComponent(e)}=${encodeURIComponent(o)}`)):`${encodeURIComponent(e)}=${encodeURIComponent(o)}`)).flat();return o.join("&")}(r);form=e("."+o),luminateExtend.api.request({api:"survey",data:c,callback:function(o){switch(i){case"ComponentForm":!function(e,o,r,i){var s,d=o,m=e.errorResponse,c=e.submitSurveyResponse;if(void 0!==m)s=m.message,n(m.code,m.message,!1,d);else if(void 0!==c.errors){m=c.errors;let e=c.errors||{};if(void 0===e.errorCode)for(let o in e)n(e[o].errorCode,e[o].errorMessage,null!=e[o].errorField?e[o].errorField:void 0!==e[o].questionInError&&e[o].questionInError,d);else n(e.errorCode,e.errorMessage,null!=e.errorField?e.errorField:void 0!==e.questionInError&&e.questionInError,d)}if(void 0!==c.errors)void 0!==s&&d.prepend('

'+s??"

");else{if(d.children().hide(),d.prepend(t(i)),d.attr("data-emailsignup"))try{window._dtm("track","email_submit")}catch(e){}a(d,d[0].SURVEY_ID.value,d[0].name),r&&(window.location.href=r)}}(o,form,d,m);break;case"SignUp":!function(o,r,i,n,d,m){var c,l=r,u=o.errorResponse,p=o.submitSurveyResponse;void 0!==u?c=u.message:void 0!==p.errors&&"1734"===(u=p.errors).errorCode&&(c="We are not able to sign you up, as you are signed in as a different user.");void 0!==c?l.prepend('

'+c+"

"):(l.children().hide(),l.prepend(t(n)),Cookies.set("stc-sign-up-submitted",1,{expires:365,path:"/",domain:window.cookieDomain}),function(o,r){var i=new e.Deferred,n=void 0!==Cookies.get("stc-member")?JSON.parse(Cookies.get("stc-member")):Cookies.get("stc-member"),t=new e.Deferred,a=new e.Deferred;void 0===(void 0!==Cookies.get("stc-logged-in")?JSON.parse(Cookies.get("stc-logged-in")):Cookies.get("stc-logged-in"))?(Cookies.remove("stc-member",{path:"/",domain:window.cookieDomain}),n={},void 0!==r&&(n.firstName=r),Cookies.set("stc-member",n,{expires:365,path:"/",domain:window.cookieDomain}),c=new e.Deferred,l=new e.Deferred,u=new e.Deferred,e.when(s(19)).done((function(e){m=e,u.resolve()})),e.when(s(75)).done((function(e){d=e,l.resolve()})),e.when(u,l).done((function(){!function(o,r){var i,n,t=r.getUserInteractionsResponse,s=o.getUserInteractionsResponse,a=void 0!==Cookies.get("stc-member")?JSON.parse(Cookies.get("stc-member")):Cookies.get("stc-member");return void 0!==s&&void 0!==t&&(n=e.isEmptyObject(s)&&e.isEmptyObject(t)?"autoregistration":e.isEmptyObject(t)&&!e.isEmptyObject(s)&&!Array.isArray(s.interaction)||e.isEmptyObject(s)&&!e.isEmptyObject(t)&&!Array.isArray(t.interaction)?"activation":"sign in"),void 0!==n?(void 0!==a&&""!==a||(a={}),a.loginType=n,i=n,Cookies.set("stc-member",a,{expires:365,path:"/",domain:window.cookieDomain})):(void 0!==o.errorResponse&&o.errorResponse.message,void 0!==r.errorResponse&&r.errorResponse.message,i=!1),i}(m,d)?c.reject():c.resolve()})),a=c,t=function(){var o=new e.Deferred;return luminateExtend.api({api:"cons",callback:function(r){!function(o){var r=!0,i=(o.errorResponse,o.getConsResponse),n=void 0!==Cookies.get("stc-member")?JSON.parse(Cookies.get("stc-member")):Cookies.get("stc-member");void 0===n&&(n={});"object"==(void 0===i?"undefined":typeof i)?(n.firstName=i.name.first,n.consId=i.cons_id,null!==i.member_id&&(n.donorId=i.member_id),"true"===i.custom.boolean[0].content?n.isSponsor=1:n.isSponsor=0,"true"===i.custom.boolean[1].content?n.isPartner=1:n.isPartner=0,"true"===i.custom.boolean[2].content?n.isFaf=1:n.isFaf=0,"true"===i.custom.boolean[4].content?n.isDonor=1:n.isDonor=0,Cookies.set("stc-member",n,{expires:365,path:"/",domain:window.cookieDomain}),Cookies.set("stc-logged-in",1,{path:"/",domain:window.cookieDomain}),function(o){void 0!==Cookies.get("stc-logged-in")&&(e(".greeting-message, .user-account, .user-sign-out").removeClass("visually-hidden"),e(".user-sign-in").addClass("visually-hidden"),null!==o&&e(".greeting-message").append(o));$body}(i.name.first)):r=!1;return r}(r)?o.reject():o.resolve()},data:"method=getUser",requiresAuth:!0,useHTTPS:!0}),o}(),e.when(a,t).done((function(){!function(o){var r,i=function(){var e=!1,o=void 0!==Cookies.get("stc-social-login")?JSON.parse(Cookies.get("stc-social-login")):Cookies.get("stc-social-login");void 0!==o&&(e=void 0!==o.formType?o.formType+":"+o.socialMedia:":"+o.socialMedia);return Cookies.remove("stc-social-login",{path:"/"}),e}();i&&(3===i.length?o+=i:o=-1!==o.indexOf("sign in")?o.replace("sign in",i):-1!==o.indexOf("registration")?o.replace("registration",i):i);r=function(e){var o=void 0!==Cookies.get("stc-member")?JSON.parse(Cookies.get("stc-member")):Cookies.get("stc-member"),r=o.loginType;"registration"===e&&(r=r.replace("auto",""));return o.loginType=r,Cookies.set("stc-member",o,{expires:365,path:"/",domain:window.cookieDomain}),r}(o),void 0!==o&&void 0!==r&&function(o,r){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];"undefined"==typeof $body&&($body=e("body"));try{i&&window._dtm("setUserData",$body),window._dtm("setRegistration",{location:o,loginType:r}),window._dtm("track","site_reg_login")}catch(e){}}(o,r,!0)}(o),setTimeout(i.resolve,1e3)})).fail((function(){i.reject("user-not-logged-in")}))):i.reject("logged-in");var d,m,c,l,u}("sign up",d),dataLayer=dataLayer||[],dataLayer.push({event:"onemail",type:"marketing",email:m}),window._dtm("track","email_submit"),a(r,r[0].SURVEY_ID.value,r[0].name),i&&(window.location.href=i))}(o,form,d,m,r.cons_first_name,r.cons_email);break;case"PledgeForm":!function(e,o,r,i){var n,s=o,a=e.errorResponse,d=e.submitSurveyResponse;void 0!==a?n=a.message:void 0!==d.errors&&"1734"===(a=d.errors).errorCode&&(n="We are not able to sign you up, as you are signed in as a different user.");void 0!==n?s.prepend('

'+n+"

"):(s.children().hide(),s.prepend(t(i)),r&&(window.location.href=r))}(o,form,d,m)}},requiresAuth:!0,useHTTPS:!0})},e.fn.detectRegistrationState=function(){var o=this;return void 0!==Cookies.get("stc-sign-up-submitted")&&(o.addClass("survey-submitted"),e(".webform-component--esignup").hide()),void 0!==Cookies.get("stc-member")&&(o.addClass("logged-in"),e(".webform-component--esignup").hide()),o},$body.detectRegistrationState()}}}(jQuery,Drupal,drupalSettings);